YambUpdown = {
	name: "updown",
	yamb: null,
	
	init: function() {
		this.yamb.table.find("td.field[game_column="+this.name+"]").eq(0).addClass("toplay");
		this.yamb.table.find("td.field[game_column="+this.name+"]").eq(12).addClass("toplay");
	},
	
	play: function(td) {
		if(this.yamb.toPlay(td)) {
			var value = this.yamb.getGameValue(td.attr("game_row"));
			td.html(value);
			td.addClass("played").removeClass("toplay");
			
			nextRow = this.getNextRow(td);
			if(nextRow !== false && nextRow != 0) {
				next = nextRow.find("td.field[game_column="+this.name+"]");
				if(next.length) {
					next.addClass("toplay");
				}
			}
			return true;
		}
		return false;
	},
	undo: function(td) {
		nextRow = this.getNextRow(td);
		if(nextRow !== false) {
			td.addClass("toplay").removeClass("played");
			if(nextRow != 0) {
				var next = nextRow.find("td.field[game_column="+this.name+"]");
				if(next.length) {
					next.removeClass("toplay");
				}
			}
		}
	},
	
	getNextRow: function(td) {
		var nextRow=false;
		switch(td.attr("game_row")) {
			case "1":
			case "2":
			case "3":
			case "4":
			case "5":
			case "6":
				var nextRow = td.parent().next();
				if(nextRow.hasClass("sum")) {
					nextRow = nextRow.next();
				}
				break;
			
			case "straight":
			case "trilling":
			case "full":
			case "poker":
			case "yamb":
				var nextRow = td.parent().prev();
				if(nextRow.hasClass("sum")) {
					nextRow = nextRow.prev();
				}
				break;
			
			case "max":
			case "min":
				nextRow = 0;
				break;
		}
		return nextRow;
	}
};